package com.web;

import com.pojo.UserInfo;
import com.service.UserInfoService;
import com.service.impl.UserInfoServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class MedicalServlet extends HttpServlet {

    private UserInfoService userInfoService = new UserInfoServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        UserInfo loginUser = userInfoService.login(new UserInfo(null, username, password));
        if (loginUser == null) {
            request.setAttribute("msg", "用户名或密码错误！");
            request.getRequestDispatcher("/index.jsp").forward(request, response);
        } else {
            request.getRequestDispatcher("/medicalServletList").forward(request, response);
        }
    }
}
